import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { LoginModule } from './admin/modules/login/login.module';
//import { RedisModule } from './redis/redis.module';

import { ConfigModule, ConfigService } from '@nestjs/config';

import Config from './config'
import { TypeOrmModule } from '@nestjs/typeorm';
import { AdministratorModelModule } from './models/administrator-model/administrator-model.module';
import { BaseModule } from './models/base/base.module';
import { UploadModule } from './admin/modules/upload/upload.module';
import { AliossModule } from './alioss/alioss.module';
import { PublishModule } from './admin/modules/publish/publish.module';
import { VoteModelModule } from './models/vote-model/vote-model.module';
import { VoteOptionModelModule } from './models/vote-option-model/vote-option-model.module';
import { VoteModule } from './admin/modules/vote/vote.module';
import { VoteLogModelModule } from './models/vote-log-model/vote-log-model.module';
import { UserModule } from './models/user/user.module';


@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal : true,
      load : [Config],
    }),

    TypeOrmModule.forRootAsync({
        imports: [ConfigModule],
        inject : [ConfigService],
        useFactory : async (configService : ConfigService) => {
            return {
            parse : false,
            ...configService.get('database')
            }
        }
    }),

    //RedisModule,
	

    LoginModule,

    AdministratorModelModule,

    BaseModule,

    UploadModule,

    AliossModule,

    PublishModule,

    VoteModelModule,

    VoteOptionModelModule,

    VoteModule,

    VoteLogModelModule,

    UserModule

  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
